﻿/** 坐标数据 */
class CoordsData {
  /** 预设坐标数据 */
  data := {
    21x9: {
      mode: "21x9",
      ratio: 2.33,
      角色操作: {
        鼠标右键: [1400, 1020, 1700, 1050, 0xffff00],
        Q: [1700, 1020, 1821, 1050, 0xffffff],
        T: [355, 35, 375, 60, 0xffffff],
        Tab: [1825, 116, 1865, 141, 0xffffff],
        取消正在处理: [763, 608, 777, 644, 0xcb0000]
      },
      快捷手册: {
        挑战_灰色: [1230, 130, 1280, 170, 0xbbbbbb],
        挑战_黑色: [1230, 130, 1280, 170, 1256, 151, 0x000000],
        零号空洞: [445, 454, 535, 489, 491, 477, 0xaaaaaa],
        前往: [1318, 420, 1365, 454, 1341, 433, 0xffffff],
        传送: [982, 601, 1003, 647, 1083, 627, 0x00cc0d]
      },
      零号选择: {
        资质考核: [419, 721, 469, 749, 0x78cc00],
        旧都列车: [676, 824, 809, 856, 742, 788, 0x78cc00],
        施工废墟: [750, 410, 846, 435, 0x78cc00]
      },
      旧都列车: {
        前线: [1683, 340, 1829, 412, 1753, 377, 0xbff700],
        下一步: [1723, 1010, 1791, 1046, 1757, 1025, 0xffffff]
      },
      空洞: {
        确认: [877, 605, 889, 660, 971, 626, 0x00cc0d],
        确定: [938, 776, 985, 850, 960, 791, 0xffffff, 0.5],
        1: {
          右上终点: [1211, 210, 1290, 240, 0xf63d49],
          右下终点: [1211, 860, 1290, 920, 0xe8202a],
          战斗: {
            开始: [200, 50, 280, 90, 0x00ff44],
            计时: [1150, 400, 1300, 650, 0xffc300],
            确定键: [1050, 850, 1200, 1050, 0xffffff],
            确定绿勾: [900, 850, 1050, 1050, 0x00cc0d]
          }
        },
        2: {
          选项框: [1497, 488, 1522, 770],
          降压准备: [876, 713, 888, 770, 973, 740, 0x00cc0d]
        },
        退出副本: {
          放弃: [1663, 1003, 1680, 1048, 1768, 1027, 0xcb0000],
          确认: [991, 605, 1002, 651, 1084, 627, 0x00cc0d]
        },
        结算: {
          零号业绩: [1480, 614, 1553, 649, 0xffb500, 0.5],
          完成: [1733, 1015, 1775, 1044, 1753, 1026, 0xffffff]
        }
      },
      拿命验收: {
        xmin: 1325,
        xmax: 1350,
        返回键: [44, 20, 118, 79, 0xc01c00],
        难度格: [870, 803, 888, 824, 0xe74706],
        推荐等级: [70, 747, 149, 848, 0xcb3f4a],
        重新开始: [1425, 1011, 1441, 1045, 1532, 1029, 0xff5d00],
        丁尼: [1480, 614, 1553, 649, 0x00a9ff, 0.5]
      },
      地图: {
        2F: [1235, 945, 1278, 997, 0x793023],
        HDD: [553, 971, 564, 985, 0x386f89],
      }
    },
    16x9: {
      mode: "16x9",
      ratio: 1.78,
      快捷手册: {
        挑战_灰色: [1330, 130, 1400, 170, 0xbbbbbb],
        挑战_黑色: [1330, 130, 1400, 170, 1359, 144, 0x000000],
        零号空洞: [275, 463, 380, 490, 330, 475, 0xaaaaaa],
        前往: [1443, 419, 1508, 453, 1475, 438, 0xffffff],
        传送: [1000, 600, 1100, 640, 1125, 620, 0x00cc0d]
      },
      角色操作: {
        鼠标右键: [1400, 1020, 1700, 1050, 0xffff00],
        Q: [1700, 1020, 1790, 1050, 0xffffff],
        T: [480, 35, 510, 60, 0xffffff],
        Tab: [1800, 100, 1850, 130, 0xffffff],
        取消正在处理: [694, 605, 715, 646, 0xcb0000]
      },
      零号选择: {
        资质考核: [240, 700, 260, 750, 0x78cc00],
        旧都列车: [580, 780, 600, 850, 660, 770, 0x78cc00],
        施工废墟: [680, 410, 700, 450, 0x78cc00]
      },
      旧都列车: {
        前线: [1600, 349, 1800, 420, 1706, 374, 0xbff700],
        下一步: [1660, 960, 1740, 1040, 1707, 1028, 0xffffff]
      },
      空洞: {
        确认: [840, 620, 1000, 810, 975, 630, 0x00cc0d],
        确定: [930, 750, 985, 850, 960, 790, 0xffffff, 0.5],
        1: {
          右上终点: [1300, 210, 1400, 251, 0xf63d49],
          右下终点: [1310, 850, 1420, 930, 0xe8202a],
          战斗: {
            开始: [257, 41, 380, 96, 0x00ff44],
            计时: [1230, 430, 1370, 610, 0xffc300],
            确定键: [1130, 840, 1190, 1020, 0xffffff],
            确定绿勾: [1000, 840, 1040, 1020, 0x00cc0d]
          }
        },
        2: {
          选项框: [1360, 490, 1390, 763],
          降压准备: [850, 700, 870, 780, 960, 735, 0x00cc0d]
        },
        退出副本: {
          放弃: [1580, 960, 1600, 1050, 1712, 1026, 0xcb0000],
          确认: [1000, 600, 1100, 640, 1125, 620, 0x00cc0d]
        },
        结算: {
          零号业绩: [1320, 600, 1440, 666, 0xffb500, 0.5],
          完成: [1670, 970, 1730, 1040, 1700, 1027, 0xffffff]
        }
      },
      拿命验收: {
        xmin: 1125,
        xmax: 1150,
        返回键: [55, 19, 153, 77, 0xc01c00],
        难度格: [511, 803, 535, 827, 0xe74706],
        推荐等级: [99, 747, 201, 773, 0xcb3f4a],
        重新开始: [1258, 1010, 1273, 1046, 1397, 1027, 0xff5d00],
        丁尼: [1320, 600, 1440, 666, 0x00a9ff, 0.5]
      },
      地图: {
        2F: [1334, 944, 1369, 1006, 0x793023],
        HDD: [415, 973, 430, 984, 0x386f89],
      }
    },
    16x10: {
      mode: "16x10", ; 2560x1600
      ratio: 1.60,
      角色操作: {
        鼠标右键: [1400, 1020, 1700, 1050, 0xffff00],
        Q: [1700, 1020, 1790, 1050, 0xffffff],
        T: [480, 30, 500, 55, 0xffffff],
        Tab: [1800, 100, 1850, 130, 0xffffff],
        取消正在处理: [690, 600, 720, 640, 0xcb0000]
      },
      快捷手册: {
        挑战_灰色: [1330, 170, 1400, 210, 0xbbbbbb],
        挑战_黑色: [1330, 170, 1400, 210, 1361, 186, 0x000000],
        零号空洞: [275, 463, 380, 490, 330, 475, 0xaaaaaa],
        前往: [1447, 433, 1507, 461, 1473, 448, 0xffffff],
        传送: [1000, 600, 1100, 640, 1125, 620, 0x00cc0d]
      },
      零号选择: {
        资质考核: [240, 700, 260, 750, 0x78cc00],
        旧都列车: [580, 780, 600, 850, 660, 770, 0x78cc00],
        施工废墟: [680, 410, 700, 450, 0x78cc00]
      },
      旧都列车: {
        前线: [1600, 349, 1800, 420, 1706, 374, 0xbff700],
        下一步: [1660, 960, 1740, 1040, 1707, 1028, 0xffffff]
      },
      空洞: {
        确认: [840, 620, 1000, 810, 975, 630, 0x00cc0d],
        确定: [930, 750, 985, 850, 960, 790, 0xffffff, 0.5],
        1: {
          右上终点: [1300, 220, 1400, 280, 0xf63d49],
          右下终点: [1300, 840, 1400, 920, 0xe8202a],
          战斗: {
            开始: [261, 46, 369, 72, 0x00ff44],
            计时: [1230, 430, 1380, 610, 0xffc300],
            确定键: [1130, 780, 1190, 1020, 0xffffff],
            确定绿勾: [1000, 780, 1040, 1020, 0x00cc0d]
          }
        },
        2: {
          选项框: [1360, 490, 1390, 763],
          降压准备: [850, 700, 870, 750, 970, 720, 0x00cc0d]
        },
        退出副本: {
          放弃: [1580, 960, 1600, 1050, 1712, 1026, 0xcb0000],
          确认: [1000, 600, 1100, 640, 1125, 620, 0x00cc0d]
        },
        结算: {
          零号业绩: [1320, 600, 1440, 666, 0xffb500, 0.5],
          完成: [1670, 970, 1730, 1040, 1700, 1027, 0xffffff]
        }
      },
      拿命验收: {
        xmin: 1125,
        xmax: 1150,
        返回键: [66, 74, 152, 124, 0xc01c00],
        难度格: [507, 778, 533, 797, 0xe74706],
        推荐等级: [101, 730, 200, 815, 0xcb3f4a],
        重新开始: [1256, 964, 1274, 996, 1399, 981, 0xff5d00],
        丁尼: [1320, 600, 1440, 666, 0x00a9ff, 0.5]
      },
      地图: {
        2F: [1337, 905, 1383, 953, 0x793023],
        HDD: [412, 929, 430, 940, 0x386f89],
      }
    },
    4x3: {
      mode: "4x3", ; 2560x1920
      ratio: 1.33,
      角色操作: {
        鼠标右键: [1400, 1020, 1750, 1050, 0xffff00],
        Q: [1700, 1020, 1785, 1050, 0xffffff],
        T: [480, 25, 500, 50, 0xffffff],
        Tab: [1804, 90, 1846, 104, 0xffffff],
        取消正在处理: [690, 590, 720, 620, 0xcb0000]
      },
      快捷手册: {
        挑战_灰色: [1330, 230, 1400, 260, 0xbbbbbb],
        挑战_黑色: [1330, 230, 1400, 260, 1359, 246, 0x000000],
        零号空洞: [277, 481, 378, 498, 329, 492, 0xaaaaaa],
        前往: [1445, 450, 1510, 472, 1475, 462, 0xffffff],
        传送: [998, 587, 1015, 619, 1130, 604, 0x00cc0d]
      },
      零号选择: {
        资质考核: [242, 681, 294, 692, 0x78cc00],
        旧都列车: [589, 754, 741, 768, 662, 730, 0x78cc00],
        施工废墟: [678, 444, 806, 460, 0x78cc00]
      },
      旧都列车: {
        前线: [1610, 391, 1798, 445, 1700, 415, 0xbff700],
        下一步: [1667, 896, 1737, 912, 1706, 903, 0xffffff]
      },
      空洞: {
        确认: [850, 605, 865, 636, 977, 621, 0x00cc0d],
        确定: [926, 706, 993, 780, 960, 731, 0xffffff, 0.5],
        1: {
          右上终点: [1290, 290, 1400, 340, 0xf63d49],
          右下终点: [1290, 770, 1400, 830, 0xe8202a],
          战斗: {
            开始: [261, 39, 372, 60, 0x00ff44],
            计时: [1223, 385, 1379, 590, 0xffc300],
            确定键: [1131, 780, 1208, 940, 0xffffff],
            确定绿勾: [1022, 780, 1054, 940, 0x00cc0d]
          }
        },
        2: {
          选项框: [1356, 501, 1388, 709],
          降压准备: [848, 672, 863, 710, 980, 690, 0x00cc0d]
        },
        退出副本: {
          放弃: [1578, 890, 1602, 919, 1721, 907, 0xcb0000],
          确认: [1001, 592, 1017, 620, 1130, 602, 0x00cc0d]
        },
        结算: {
          零号业绩: [1334, 606, 1433, 624, 0xffb500, 0.5],
          完成: [1673, 898, 1724, 916, 1699, 905, 0xffffff]
        }
      },
      拿命验收: {
        xmin: 1125,
        xmax: 1150,
        返回键: [61, 149, 154, 191, 0xc01c00],
        难度格: [510, 736, 534, 753, 0xe74706],
        推荐等级: [97, 698, 199, 768, 0xcb3f4a],
        重新开始: [1256, 890, 1276, 922, 1399, 904, 0xff5d00],
        丁尼: [1334, 606, 1433, 624, 0x00a9ff, 0.5]
      },
      地图: {
        2F: [1332, 845, 1379, 883, 0x793023],
        HDD: [412, 864, 427, 874, 0x386f89],
      }
    },
    5x4: {
      mode: "5x4", ; 2560x2048
      ratio: 1.25,
      角色操作: {
        鼠标右键: [1500, 1000, 1700, 1060, 0xffff00],
        Q: [1700, 1000, 1786, 1060, 0xffffff],
        T: [480, 20, 510, 50, 0xffffff],
        Tab: [1802, 84, 1847, 97, 0xffffff],
        取消正在处理: [700, 580, 720, 620, 0xcb0000]
      },
      快捷手册: {
        挑战_灰色: [1330, 250, 1390, 280, 0xbbbbbb],
        挑战_黑色: [1330, 250, 1390, 280, 1359, 263, 0x000000],
        零号空洞: [273, 483, 383, 503, 326, 493, 0xaaaaaa],
        前往: [1445, 457, 1505, 477, 1474, 468, 0xffffff],
        传送: [986, 589, 1016, 612, 1127, 598, 0x00cc0d]
      },
      零号选择: {
        资质考核: [240, 670, 295, 686, 0x78cc00],
        旧都列车: [581, 740, 746, 755, 662, 715, 0x78cc00],
        施工废墟: [681, 449, 804, 465, 0x78cc00]
      },
      旧都列车: {
        前线: [1608, 401, 1796, 448, 1696, 425, 0xbff700],
        下一步: [1669, 872, 1737, 890, 1700, 881, 0xffffff]
      },
      空洞: {
        确认: [848, 600, 863, 628, 970, 610, 0x00cc0d],
        确定: [935, 710, 989, 750, 960, 718, 0xffffff, 0.5],
        1: {
          右上终点: [1300, 300, 1400, 350, 0xf63d49],
          右下终点: [1300, 750, 1400, 800, 0xe8202a],
          战斗: {
            开始: [260, 36, 372, 56, 0x00ff44],
            计时: [1234, 400, 1371, 750, 0xffc300],
            确定键: [1130, 600, 1190, 950, 0xffffff],
            确定绿勾: [1100, 600, 1040, 950, 0x00cc0d]
          }
        },
        2: {
          选项框: [1358, 503, 1388, 696],
          降压准备: [850, 664, 870, 700, 979, 680, 0x00cc0d]
        },
        退出副本: {
          放弃: [1579, 871, 1599, 895, 1719, 880, 0xcb0000],
          确认: [1003, 592, 1018, 615, 1124, 600, 0x00cc0d]
        },
        结算: {
          零号业绩: [1342, 594, 1427, 626, 0xffb500, 0.5],
          完成: [1676, 872, 1727, 891, 1700, 882, 0xffffff]
        }
      },
      拿命验收: {
        xmin: 1125,
        xmax: 1150,
        返回键: [65, 176, 150, 215, 0xc01c00],
        难度格: [510, 725, 532, 740, 0xe74706],
        推荐等级: [98, 687, 200, 756, 0xcb3f4a],
        重新开始: [1259, 869, 1274, 897, 1400, 882, 0xff5d00],
        丁尼: [1342, 594, 1427, 626, 0x00a9ff, 0.5]
      },
      地图: {
        2F: [1336, 826, 1379, 863, 0x793023],
        HDD: [412, 844, 428, 851, 0x386f89],
      }
    },
    ; 模板: {
    ;   角色操作: {
    ;     鼠标右键: [0xffff00], ; 4个所需坐标参数，左上XY、右下XY
    ;     Q: [0xffffff],
    ;     T: [0xffffff],
    ;     Tab: [0xffffff],
    ;     取消正在处理: [0xcb0000]
    ;   },
    ;   快捷手册: {
    ;     挑战_灰色: [0xbbbbbb],
    ;     挑战_黑色: [ 0x000000], ; 6个所需坐标参数，左上XY、右下XY、默认XY
    ;     零号空洞: [ 0xaaaaaa],
    ;     前往: [ 0xffffff],
    ;     传送: [ 0x00cc0d]
    ;   },
    ;   零号选择: {
    ;     资质考核: [0x78cc00],
    ;     旧都列车: [ 0x78cc00],
    ;     施工废墟: [0x78cc00]
    ;   },
    ;   旧都列车: {
    ;     前线: [ 0xbff700],
    ;     下一步: [ 0xffffff]
    ;   },
    ;   空洞: {
    ;     确认: [ 0x00cc0d], ; 有绿勾，确认侵蚀、代理人
    ;     确定: [ 0xffffff, 0.5], ; 无绿勾，铭徽确定、催化、选择
    ;     1: {
    ;       右上终点: [0xf63d49],
    ;       右下终点: [0xe8202a],
    ;       战斗: {
    ;         开始: [0x00ff44],
    ;         计时: [0xffc300], ; Y±180
    ;         确定键: [0xffffff],
    ;         确定绿勾: [0x00cc0d]
    ;       }
    ;     },
    ;     2: {
    ;       选项框: [],
    ;       降压准备: [ 0x00cc0d]
    ;     },
    ;     退出副本: {
    ;       放弃: [ 0xcb0000],
    ;       确认: [ 0x00cc0d]
    ;     },
    ;     结算: {
    ;       零号业绩: [0xffb500, 0.5],
    ;       完成: [ 0xffffff]
    ;     }
    ;   },
    ;   拿命验收: {
    ;     xmin: 1125, ; 圆心搜索范围
    ;     xmax: 1150,
    ;     返回键: [0xc01c00],
    ;     难度格: [0xe74706],
    ;     推荐等级: [0xcb3f4a],
    ;     重新开始: [ 0xff5d00],
    ;     丁尼: [0x00a9ff, 0.5]
    ;   },
    ;   地图: {
    ;     2F: [0x793023], ; 右砖
    ;     HDD: [0x386f89], ; 第二个D
    ;   }
    ; }
  }

  __New() {
    this.c := {}
    this.reset()
    this.watch()
  }

  __Get(Key, *) {
    return this.c.%Key%
  }

  reset(*) {
    windowed := false
    w := A_ScreenWidth, h := A_ScreenHeight
    if (WinExist(ZZZ)) {
      setting.GamePath := WinGetProcessPath(ZZZ)
      WinGetClientPos(, , &w, &h, ZZZ)
      if (w != A_ScreenWidth || h != A_ScreenHeight) {
        windowed := true
      }
    }
    if (this.c.HasProp('width') && w = this.c.width && h = this.c.height && this.c.windowed = windowed) {
      return
    }
    actualRatio := Round(w / h, 2)
    bestRatio := {
      diff: 251,
      key: "16x9"
    }
    for (key, value in this.data.OwnProps()) {
      designRatio := value.ratio
      ratioDiff := Abs(designRatio - actualRatio)
      if (ratioDiff < bestRatio.diff) {
        bestRatio.diff := ratioDiff
        bestRatio.key := key
      }
      if (ratioDiff = 0) {
        break
      }
    }
    this.c := this.data.%bestRatio.key%
    this.c.compatible := bestRatio.diff > 0.07
    this.c.windowed := windowed
    this.c.width := w, this.c.height := h
    global FoundDennyFuben := false ; 重置丁尼副本Found标记
  }

  watch() {
    OnMessage(0x7E, (*) => SetTimer(this.reset.Bind(this), -3000))
  }

}